#ifndef __LIB_KFIFO_H_
#define __LIB_KFIFO_H_

#define is_power_of_2(x) ((x) != 0 && (((x) & ((x) - 1)) == 0))
#define min(a, b) (((a) < (b)) ? (a) : (b))

struct kfifo {
	char *buffer;       /* data buffer */
	unsigned int size;  /* data buffer size */
	unsigned int in;    /* insert buffer pose */
	unsigned int out;   /* put buffer pose  */
};

struct kfifo *kfifo_init(char *buffer, unsigned int size);
struct kfifo *kfifo_alloc(unsigned int size);
void kfifo_free(struct kfifo *fifo);
unsigned int kfifo_put(struct kfifo *fifo, char *buffer, unsigned int size);
unsigned int kfifo_get(struct kfifo *fifo, char *buffer, unsigned int size);
unsigned int kfifo_len(struct kfifo *fifo);


#endif /* __LIB_PTHREAD_H_ */
